home *** CD-ROM | disk | FTP | other *** search
- C Example by Thomas Down
- ============================
-
- This is an example of how to write a (very) simple RISC-OS WIMP
- application in C. To use it, simply double click on its icon. Notice that
- there is an icon bar menu with info and quit options. When you click on its
- icon, a small dialog box opens containing three icons. Try clicking and
- typing to see what they do.
-
- To find out how it works, load the c.cexample file into a text editor.
- Most commands are explained by comments in the text file, but remember the
- following
-
- 1. /* ... */ is equivalent to Basic's REM ...
-
- 2. C uses a form of block structuring. {and } are used to group
- instructions together. For example, the IF command can be used with one
- conditional instruction:
-
- if(var==1)
- instruction 1
-
- or several:
-
- if (var==1) {1 ;
- ...
- instruction n;
- }
-
- 3. C uses semicolons (;) as line terminators after most instructions. The
- exceptions are instructions which are followed by one or more other
- instructions to make a statement e.g. for(), if(), while().
-
- 4. In C, the equality condition is '==' instead of Basic's '='. '=' is
- still used for assignment.
-
- -----------------------------------------------------------------------------
-
- IF YOU WANT TO RECOMPILE THE PROGRAM
-
- ANSI C v4
-
- I do not recommend using ANSI C from floppies unless absolutely necessary
-
- Open the 'c' and '!C Example' directory viewers. Now load !CC. To compile
- and link, drag the cexample file from the 'c' directory to the !CC icon.
- The default options are generally correct so simply click Run. A text
- window will open showing progress. Ignore the warning from 'link' about a
- memory shortage. When compilation is complete, a save box will appear.
- Delete the default name and type in '!RunImage' then drag the icon to the
- !C Example directory. This sounds a bit complicated, but very quickly
- becomes intuitive.
-
- BEEBUG C (v 1.50)
-
- If you are using floppy discs, copy the cexample directory onto your work
- disc
-
- 1. Load the editor
-
- 2. Check the options are correct. You will need to link with:
-
- Window library
- Event library
- Menu library
- Dialog box library
- Icon library
- Utilities library
- (if in doubt about these, use Complete WIMP)
-
- OS library
- Sprite library
- Shared C Library
-
- This is NOT the default configuration, so you MUST change it unless you
- have already reconfigured the package.
-
- 3. Load c.cexample into the editor
-
- 4. Click on the Compile menu option
-
- 5. If the compilation is successful, click on the Link menu option
-
- 6. In the directory ABOVE the 'c' directory, there should now be an APP
- file called cexample. Rename this !RunImage
-
- 7. Copy the new !RunImage into the !C Example application directory
-
-
-
-